﻿//********************************************************************************//
//创建日期：<创建日期，2016-09-29>
//创建作者：<孙雪婷，sunxueting@shanghai3h.com>
//功能说明：用户信息查询
//********************************************************************************//
using BLL;
using BLL.Access;
using DevExpress.Web;
using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Class;

namespace Web.Pages.QuShui.DiXiaS.ChaXunGL
{
    public partial class YongHuXXCX : BasePage
    {
        #region 属性

        /// <summary>
        /// 保存结果集1
        /// </summary>
        private DataTable dtYongHuXX
        {
            get
            {
                return ViewState["dtYongHuXX"] as DataTable;
            }
            set
            {
                ViewState["dtYongHuXX"] = value;
            }
        }

       
        #endregion

        #region 变量

        /// <summary>
        /// 数据访问操作类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();
        /// <summary>
        /// 行政区
        /// </summary>
        QS_JX_XINGZHENGQBLL XZQ = new QS_JX_XINGZHENGQBLL();
        /// <summary>
        /// 行业分类
        /// </summary>
        QS_JX_HANGYEFLXXBLL HYFL = new QS_JX_HANGYEFLXXBLL();
        /// <summary>
        /// 取水用途
        /// </summary>
        QS_JX_QUSHUIXXBLL QSYT = new QS_JX_QUSHUIXXBLL();
        /// <summary>
        /// 管理部门
        /// </summary>
        QS_JX_BUMENXXBLL GLBM = new QS_JX_BUMENXXBLL();
        /// <summary>
        /// 流域信息
        /// </summary>
        QS_JX_LIUYUXXBLL LYXX = new QS_JX_LIUYUXXBLL();
        /// <summary>
        /// 水利分片
        /// </summary>
        QS_JX_SHUILIFPXXBLL SLFP = new QS_JX_SHUILIFPXXBLL();
        /// <summary>
        /// 水资源分区
        /// </summary>
        QS_JX_SHUIZIYFQBLL SZYFQ = new QS_JX_SHUIZIYFQBLL();

        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //第一次页面加载
            if (!IsPostBack)
            {
                InitData();
            }
            ScriptManager1.RegisterPostBackControl(btnExport);
            this.gvYongHuXX.DataSource = this.dtYongHuXX;
            this.gvYongHuXX.DataBind();
            
        }

       


        /// <summary>
        /// 查询信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnChaXun_Click(object sender, EventArgs e)
        {
            if (txtShuiLiangYM.Text != "")
            {
                LoadGridData();
                if (this.dtYongHuXX == null || this.dtYongHuXX.Rows.Count < 1)
                {
                    txtYongHuH2.Text = "";
                    txtYongHuM2.Text = "";
                    txtHuanNeiHW.Text = "";
                    txYouBian.Text = "";
                    txtDiZhi.Text = "";
                    txtXingZhengQ.Text = "";
                    txtLianXiBM.Text = "";
                    txtLianXiR.Text = "";
                    txtLianXiDH.Text = "";
                    txtLiuYu.Text = "";
                    txtYeWuY.Text = "";
                    txtGuanLiBM.Text = "";
                    txtShuiZiYFQ.Text = "";
                    txtShouFeiFS.Text = "";
                    txtShuiJia2.Text = "";
                    txtQuShuiYT.Text = "";
                    txtShuiLiFP.Text = "";
                    txtKaiHuHM2.Text = "";
                    txtHangYeFL.Text = "";
                    memoBeiZhu.Text = "";
                    txtYinHangZH2.Text = "";
                    txtJingShu.Text = "";
                    txtKaiHuYH.Text = "";
                    txtBiaoShu.Text = "";
                    zjl.Text = "共0条";
                }
            }
        }


        /// <summary>
        /// tab1导出excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnExportExcel_Click(object sender, EventArgs e)
        {
            if (this.dtYongHuXX == null || this.dtYongHuXX.Rows.Count < 1)
            {
                PageTools.AlertMsg(this, "没有符合的数据导出");
            }
            else
            {
                PageTools.ExportExcel(this.dtYongHuXX);
            }
        }

       
        #endregion

        #region 方法

        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            int wtype = BusinessTool.WType;
            if (wtype == 2)
            {
                js.InnerText = "井数：";
            }
            else
            {
                js.InnerText = "取水口数：";
            }
            gvYongHuXX.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            //水量年月
            string water_y_m = BusinessTool.GetSLYMorZWNY(1, wtype).ToString();

            int userid = LoginInfo.CurrentUser.UserID;//当前登陆人
            if (userid == 116 || userid == 99999 || userid == 113 || userid == 111)
            {
                btnXiuGai.Visible = true;
            }

            if (wtype == 1)
            {
                rabGuanLiBM.ClientVisible = false;
                cbmGuanLiBM.ClientVisible = false;
                rabShouFeiFS.ClientVisible = false;
                cmbShouFeiFS.ClientVisible = false;
            }
           
            //业务员
            //LoadYWY();
            txtShuiLiangYM.Text = water_y_m;
            //加载管理部门
            LoadGLBM();
            //加载行政区
            LoadXZQ();
            //加载业务员
            LoadYWY();
            //加载取水用途
            LoadQSYT();
            //加载行业分类
            LoadHYFL();
            //加载流域
            LoadLY();
            //水利分片
            LoadSLFP();
            //水资源分区
            LoadSZYFQ();
        }



        /// <summary>
        /// 加载管理部门
        /// </summary>
        private void LoadGLBM()
        {
            DataTable dt = GLBM.SelectQS_JX_BUMENXXesDynamic("I_JLZT=0 and S_BUMENBH NOT IN(0,600)", "S_BUMENBH ");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cbmGuanLiBM.Items.Add(dt.Rows[i]["S_BUMENMC"].ToString(), dt.Rows[i]["S_BUMENBH"]);
            }
            cbmGuanLiBM.Items.Insert(0, new ListEditItem("", "0"));
        }

        /// <summary>
        /// 加载行政区
        /// </summary>
        private void LoadXZQ()
        {
            DataTable dt = XZQ.SelectQS_JX_XINGZHENGQsDynamic("I_JLZT=0", null);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbXingZhengQ.Items.Add(dt.Rows[i]["S_XINGZHENGQM"].ToString(), dt.Rows[i]["S_XINGZHENGQH"]);
            }
        }

        /// <summary>
        /// 加载业务员
        /// </summary>
        private void LoadYWY()
        {
            PageTools.QSLoadCombox(cmbYeWuY, PageTools.eLoadType.业务员QS, null, "");
        }


        /// <summary>
        /// 加载 取水用途
        /// </summary>
        private void LoadQSYT()
        {
            DataTable dt = QSYT.SelectQS_JX_QUSHUIXXesDynamic("I_JLZT=0", null);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbQuShuiYT.Items.Add(dt.Rows[i]["S_QUSHUIMC"].ToString(), dt.Rows[i]["S_QUSHUIBH"]);
            }
            cmbQuShuiYT.Items.Insert(0, new ListEditItem("", "0"));
        }
        /// <summary>
        /// 加载行业分类
        /// </summary>
        private void LoadHYFL()
        {
            DataTable dt = HYFL.SelectQS_JX_HANGYEFLXXesDynamic("I_JLZT=0", "S_FENLEIBH");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbHangYeLX.Items.Add(dt.Rows[i]["S_FENLEIMC"].ToString(), dt.Rows[i]["S_FENLEIBH"]);
            }
            cmbHangYeLX.Items.Insert(0, new ListEditItem("", "0"));
        }

        /// <summary>
        /// 加载流域
        /// </summary>
        private void LoadLY()
        {
            DataTable dt = LYXX.SelectQS_JX_LIUYUXXesDynamic("I_JLZT=0", null);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbLiuYu.Items.Add(dt.Rows[i]["S_LIUYUMC"].ToString(), dt.Rows[i]["S_LIUYUBH"]);
            }
            cmbLiuYu.Items.Insert(0, new ListEditItem("", "0"));
        }

        /// <summary>
        /// 加载水利分片
        /// </summary>
        private void LoadSLFP()
        {
            DataTable dt = SLFP.SelectQS_JX_SHUILIFPXXesDynamic("I_JLZT=0", null);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbShuiLiFP.Items.Add(dt.Rows[i]["S_SHUILIFPMC"].ToString(), dt.Rows[i]["S_SHUILIFPBH"]);
            }
            cmbShuiLiFP.Items.Insert(0, new ListEditItem("", "0"));
        }

        /// <summary>
        /// 加载水资源分区
        /// </summary>
        private void LoadSZYFQ()
        {
            DataTable dt = SZYFQ.SelectQS_JX_SHUIZIYFQsDynamic("I_JLZT=0", null);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbShuiZiYFQ.Items.Add(dt.Rows[i]["S_SHUIZIYMC"].ToString(), dt.Rows[i]["S_SHUIZIYBH"]);
            }
            cmbShuiZiYFQ.Items.Insert(0, new ListEditItem("", "0"));
        }
        /// <summary>
        /// 加载查询数据
        /// </summary>
        private void LoadGridData()
        {
            int wtype = BusinessTool.WType;
            int ym = Convert.ToInt32(txtShuiLiangYM.Text);
            int hnhw = cmbHuanNeiHW.Value != null ? Convert.ToInt32(cmbHuanNeiHW.Value) : 0;
            string xzq = cmbXingZhengQ.Text != "全部" ? cmbXingZhengQ.Value.ToString() : null;
            string ywy = cmbYeWuY.Value != null && cmbYeWuY.Value.ToString() != "-1" ? cmbYeWuY.Value.ToString() : null;
            int v_bs = -1;
            string v_val = null;
            //1 用户号，2 用户名，3 用户地址，4 取水用途，5 行业类型 ，6 管理部门 ，
            //7 水价 ，8 流域，9 水利分片，10 水资源分区，11 收费方式，12 开户户名，13 银行帐号
            if (chkYongHuH.Checked && txtYongHuH.Text != "")
            {
                v_bs = 1;
                v_val = txtYongHuH.Text;
            }
            else if (chkYongHuM.Checked && txtYongHuM.Text != "")
            {
                v_bs = 2;
                v_val = txtYongHuM.Text;
            }
            else if (chkYongHuDZ.Checked && txtYongHuDZ.Text != "")
            {
                v_bs = 3;
                v_val = txtYongHuDZ.Text;
            }
             else if (rabQuShuiYT.Checked && cmbQuShuiYT.Text != "")
            {
                v_bs =4 ;
                v_val = cmbQuShuiYT.Value.ToString();
            }
             else if (rabHangYeLX.Checked && cmbHangYeLX.Text != "")
            {
                v_bs = 5;
                v_val = cmbHangYeLX.Value.ToString();
            }
             else if (rabGuanLiBM.Checked && cbmGuanLiBM.Text != "")
            {
                v_bs = 6;
                v_val = cbmGuanLiBM.Value.ToString();
            }
             else if (rabShuiJia.Checked && cmbShuiJia.Text != ""&& txtShuiJia.Text != "")
            {
                v_bs = 7;
                v_val = cmbShuiJia.Text+txtShuiJia.Text;
            }
             else if (rabLiuYu.Checked && cmbLiuYu.Text != "")
            {
                v_bs = 8;
                v_val = cmbLiuYu.Value.ToString();
            }
             else if (rabShuiLiFP.Checked && cmbShuiLiFP.Text != "")
            {
                v_bs = 9;
                v_val = cmbShuiLiFP.Value.ToString();
            }
             else if (rabShuiZiYFQ.Checked && cmbShuiZiYFQ.Text != "")
            {
                v_bs = 10;
                v_val = cmbShuiZiYFQ.Value.ToString();
            }
             else if (rabShouFeiFS.Checked && cmbShouFeiFS.Text != "")
            {
                v_bs = 11;
                v_val = cmbShouFeiFS.Value.ToString();
            }
             else if (rabKaiHuHM.Checked && txtKaiHuHM.Text != "")
            {
                v_bs = 12;
                v_val = txtKaiHuHM.Text;
            }
             else if (rabYinHangZH.Checked && txtYinHangZH.Text != "")
            {
                v_bs = 13;
                v_val = txtYinHangZH.Text;
            }
            this.dtYongHuXX = _SpHelper.P_QSCX_YONGHUXXCX(wtype, ym, hnhw, xzq, ywy, v_bs, v_val, 0).Tables[0];

            if (wtype == 1)
            {
                gvYongHuXX.Columns.Clear();
                LoadColumnDate(gvYongHuXX, "S_YONGHUH", "用户号", 60);
                LoadColumnDate(gvYongHuXX, "S_YONGHUM", "用户名", 200);
                LoadColumnDate(gvYongHuXX, "S_DIZHI", "用户地址", 200);
                LoadColumnDate(gvYongHuXX, "S_XINGZHENGQBH", "行政区号", 70);
                LoadColumnDate(gvYongHuXX, "S_XINGZHENGQM", "行政区名", 70);
                LoadColumnDate(gvYongHuXX, "S_YEWUY", "业务员", 60);
                LoadColumnDate(gvYongHuXX, "S_LIUYUMC", "流域", 50);
                LoadColumnDate(gvYongHuXX, "S_SHUIZIYMC", "水资源分区", 80);
                LoadColumnDate(gvYongHuXX, "S_SHUILIFPMC", "水利分片", 80);
                LoadColumnDate(gvYongHuXX, "HNHW", "环内环外", 70);
                LoadColumnDate(gvYongHuXX, "S_QUSHUIMC", "取水用途", 80);
                LoadColumnDate(gvYongHuXX, "S_FENLEIMC", "行业分类", 80);
                LoadColumnDate(gvYongHuXX, "N_SHUIJIA", "水价", 60, "0.00");
                LoadColumnDate(gvYongHuXX, "S_YOUBIAN", "邮政编码", 80);
                LoadColumnDate(gvYongHuXX, "S_LIANXIR", "联系人", 90);
                LoadColumnDate(gvYongHuXX, "S_DIANHUA", "联系电话", 100);
                LoadColumnDate(gvYongHuXX, "S_LIANXIBM", "联系部门", 100);
                LoadColumnDate(gvYongHuXX, "S_KAIHUHM", "开户户名", 200);
                LoadColumnDate(gvYongHuXX, "S_KAIHUH", "银行帐号", 200);
                LoadColumnDate(gvYongHuXX, "S_KAIHUYH", "开户银行", 200);
                LoadColumnDate(gvYongHuXX, "JS", "取水口数", 50);
                LoadColumnDate(gvYongHuXX, "BS", "表数", 50);
                LoadColumnDate(gvYongHuXX, "D_TIANJIARQ", "开户日期", 80, "yyyy-MM-dd");
                LoadColumnDate(gvYongHuXX, "S_HETONGH", "合同号", 280);
                LoadColumnDate(gvYongHuXX, "S_ZHUSHI", "备注", 200);

            }
            else
            {
                gvYongHuXX.Columns.Clear();
                LoadColumnDate(gvYongHuXX, "S_YONGHUH", "用户号", 60);
                LoadColumnDate(gvYongHuXX, "S_YONGHUM", "用户名", 200);
                LoadColumnDate(gvYongHuXX, "S_DIZHI", "用户地址", 200);
                LoadColumnDate(gvYongHuXX, "S_XINGZHENGQBH", "行政区号", 70);
                LoadColumnDate(gvYongHuXX, "S_XINGZHENGQM", "行政区名", 70);
                LoadColumnDate(gvYongHuXX, "S_YEWUY", "业务员", 60);
                LoadColumnDate(gvYongHuXX, "S_BUMENBH", "部门编号", 70);
                LoadColumnDate(gvYongHuXX, "S_BUMENMC", "管理部门", 130);
                LoadColumnDate(gvYongHuXX, "S_LIUYUMC", "流域", 50);
                LoadColumnDate(gvYongHuXX, "S_SHUIZIYMC", "水资源分区", 80);
                LoadColumnDate(gvYongHuXX, "S_SHUILIFPMC", "水利分片", 80);
                LoadColumnDate(gvYongHuXX, "HNHW", "环内环外", 70);
                LoadColumnDate(gvYongHuXX, "S_QUSHUIMC", "取水用途", 80);
                LoadColumnDate(gvYongHuXX, "S_FENLEIMC", "行业分类", 80);
                LoadColumnDate(gvYongHuXX, "N_SHUIJIA", "水价", 60, "0.00");
                LoadColumnDate(gvYongHuXX, "S_YOUBIAN", "邮政编码", 80);
                LoadColumnDate(gvYongHuXX, "S_LIANXIR", "联系人", 90);
                LoadColumnDate(gvYongHuXX, "S_DIANHUA", "联系电话", 100);
                LoadColumnDate(gvYongHuXX, "S_LIANXIBM", "联系部门", 100);
                LoadColumnDate(gvYongHuXX, "SFFS", "收费方式", 60);
                LoadColumnDate(gvYongHuXX, "S_KAIHUHM", "开户户名", 200);
                LoadColumnDate(gvYongHuXX, "S_KAIHUH", "银行帐号", 200);
                LoadColumnDate(gvYongHuXX, "S_KAIHUYH", "开户银行", 200);
                LoadColumnDate(gvYongHuXX, "JS", "井数", 50);
                LoadColumnDate(gvYongHuXX, "BS", "表数", 50);
                LoadColumnDate(gvYongHuXX, "D_TIANJIARQ", "开户日期", 80, "yyyy-MM-dd");
                LoadColumnDate(gvYongHuXX, "S_HETONGH", "合同号", 280);
                LoadColumnDate(gvYongHuXX, "S_ZHUSHI", "备注", 200);
            }



            gvYongHuXX.DataSource = this.dtYongHuXX;
            gvYongHuXX.DataBind();
            if (this.dtYongHuXX != null && this.dtYongHuXX.Rows.Count > 0)
            {
                zjl.Text = "共" + this.dtYongHuXX.Rows.Count.ToString() + "条";
                gvYongHuXX.FocusedRowIndex = 0;
                SetData();
            }

        }

        /// <summary>
        /// 给显示框赋值
        /// </summary>
        private void SetData()
        {
            DataTable dt_temp = _SpHelper.P_QSCX_YONGHUXXCX(BusinessTool.WType, 0, 0, "0", "0", -1, null, Convert.ToInt32(gvYongHuXX.GetRowValues(0, "ID"))).Tables[0];
            if (dt_temp != null && dt_temp.Rows.Count > 0)
            {
                txtYongHuH2.Text = dt_temp.Rows[0]["S_YONGHUH"].ToString();
                txtYongHuM2.Text = dt_temp.Rows[0]["S_YONGHUM"].ToString();
                txtHuanNeiHW.Text = dt_temp.Rows[0]["HNHW"].ToString();
                txYouBian.Text = dt_temp.Rows[0]["S_YOUBIAN"].ToString();
                txtDiZhi.Text = dt_temp.Rows[0]["S_DIZHI"].ToString();
                txtXingZhengQ.Text = dt_temp.Rows[0]["S_XINGZHENGQM"].ToString();
                txtLianXiBM.Text = dt_temp.Rows[0]["S_LIANXIBM"].ToString();
                txtLianXiR.Text = dt_temp.Rows[0]["S_LIANXIR"].ToString();
                txtLianXiDH.Text = dt_temp.Rows[0]["S_DIANHUA"].ToString();
                txtLiuYu.Text = dt_temp.Rows[0]["S_LIUYUMC"].ToString();
                txtYeWuY.Text = dt_temp.Rows[0]["S_YEWUY"].ToString();
                txtGuanLiBM.Text = dt_temp.Rows[0]["S_BUMENMC"].ToString();
                txtShuiZiYFQ.Text = dt_temp.Rows[0]["S_SHUIZIYMC"].ToString();
                txtShouFeiFS.Text = dt_temp.Rows[0]["SFFS"].ToString();
                txtShuiJia2.Text = dt_temp.Rows[0]["N_SHUIJIA"].ToString();
                txtQuShuiYT.Text = dt_temp.Rows[0]["S_QUSHUIMC"].ToString();
                txtShuiLiFP.Text = dt_temp.Rows[0]["S_SHUILIFPMC"].ToString();
                txtKaiHuHM2.Text = dt_temp.Rows[0]["S_KAIHUHM"].ToString();
                txtHangYeFL.Text = dt_temp.Rows[0]["S_FENLEIMC"].ToString();
                memoBeiZhu.Text = dt_temp.Rows[0]["S_ZHUSHI"].ToString();
                txtYinHangZH2.Text = dt_temp.Rows[0]["S_KAIHUH"].ToString();
                txtJingShu.Text = dt_temp.Rows[0]["JS"].ToString();
                txtKaiHuYH.Text = dt_temp.Rows[0]["S_KAIHUYH"].ToString();
                txtBiaoShu.Text = dt_temp.Rows[0]["BS"].ToString();
            }
        }

        /// <summary>
        /// 前台表格行改变事件回调方法
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void ASPxCallback1_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {
            int wtype = BusinessTool.WType;
            int id = Convert.ToInt32(this.hdCollection.Get("ID"));
            if (e.Parameter == "setinfo")
            {
                string msg = "";
                if (this.dtYongHuXX != null)
                {
                    DataTable dt_temp = _SpHelper.P_QSCX_YONGHUXXCX(wtype, 0, 0, "0", "0", -1, null, id).Tables[0];

                    msg = string.Join("|", 
                        dt_temp.Rows[0]["S_YONGHUH"].ToString(),
                        dt_temp.Rows[0]["S_YONGHUM"].ToString(),
                         dt_temp.Rows[0]["HNHW"].ToString(),
                        dt_temp.Rows[0]["S_YOUBIAN"].ToString(),
                        dt_temp.Rows[0]["S_DIZHI"].ToString(),
                        dt_temp.Rows[0]["S_XINGZHENGQM"].ToString(),
                        dt_temp.Rows[0]["S_LIANXIBM"].ToString(),
                        dt_temp.Rows[0]["S_LIANXIR"].ToString(),
                        dt_temp.Rows[0]["S_DIANHUA"].ToString(),
                        dt_temp.Rows[0]["S_LIUYUMC"].ToString(),
                        dt_temp.Rows[0]["S_YEWUY"].ToString(),
                        dt_temp.Rows[0]["S_BUMENMC"].ToString(),
                         dt_temp.Rows[0]["S_SHUIZIYMC"].ToString(),
                         dt_temp.Rows[0]["SFFS"].ToString(),
                        dt_temp.Rows[0]["N_SHUIJIA"].ToString(),
                        dt_temp.Rows[0]["S_QUSHUIMC"].ToString(),
                        dt_temp.Rows[0]["S_SHUILIFPMC"].ToString(),
                        dt_temp.Rows[0]["S_KAIHUHM"].ToString(),
                        dt_temp.Rows[0]["S_FENLEIMC"].ToString(),
                        dt_temp.Rows[0]["S_ZHUSHI"].ToString(),
                        dt_temp.Rows[0]["S_KAIHUH"].ToString(),
                        dt_temp.Rows[0]["JS"].ToString(),
                        dt_temp.Rows[0]["S_KAIHUYH"].ToString(),
                        dt_temp.Rows[0]["BS"].ToString());
                }

                e.Result = e.Parameter + "|0|" + msg;
            }
        }
        #endregion

        private void LoadColumnDate(ASPxGridView gv, string fieldName, string caption, int width)
        {
            GridViewDataTextColumn c = new GridViewDataTextColumn();
            c.FieldName = fieldName;
            c.Caption = caption;
            c.Width = width;
            gv.Columns.Add(c);
        }

        private void LoadColumnDate(ASPxGridView gv, string fieldName, string caption, int width, string format)
        {
            GridViewDataTextColumn c = new GridViewDataTextColumn();
            c.FieldName = fieldName;
            c.Caption = caption;
            c.Width = width;
            c.PropertiesEdit.DisplayFormatString = format;
            gv.Columns.Add(c);
        }

        protected void btnExport_Click(object sender, EventArgs e)
        {
            //this.ASPxGridViewExporter1.GridViewID = "gvYongHuXX";
            //this.gvYongHuXX.DataSource = this.dtYongHuXX;
            //this.gvYongHuXX.DataBind();
            string sName = txtShuiLiangYM.Text + "用户信息";
            ASPxGridViewExporter1.WriteXlsToResponse(sName);

            //if (this.dtYongHuXX.Rows.Count > 0)
            //{
            //    DataTable dt = new DataTable();
            //    dt.Columns.Add("用户号");
            //    dt.Columns.Add("用户名");
            //    dt.Columns.Add("用户地址");
            //    dt.Columns.Add("行政区号");
            //    dt.Columns.Add("行政区名");
            //    dt.Columns.Add("业务员");
            //    dt.Columns.Add("部门编号");
            //    dt.Columns.Add("管理部门");
            //    dt.Columns.Add("流域");
            //    dt.Columns.Add("水资源分区");
            //    dt.Columns.Add("水利分片");
            //    dt.Columns.Add("环内环外");
            //    dt.Columns.Add("取水用途");
            //    dt.Columns.Add("行业分类");
            //    dt.Columns.Add("水价");
            //    dt.Columns.Add("邮政编码");
            //    dt.Columns.Add("联系人");
            //    dt.Columns.Add("联系电话");
            //    dt.Columns.Add("联系部门");
            //    dt.Columns.Add("收费方式");
            //    dt.Columns.Add("开户户名");
            //    dt.Columns.Add("银行帐号");
            //    dt.Columns.Add("开户银行");
            //    dt.Columns.Add("井数");
            //    dt.Columns.Add("表数");
            //    dt.Columns.Add("开户日期"); dt.Columns.Add("合同号"); dt.Columns.Add("备注");
            //    for (int i = 0; i < this.gvYongHuXX.VisibleRowCount; i++)
            //    {
            //        DataRow dr = dt.NewRow();
            //        dr["用户号"] = this.gvYongHuXX.GetRowValues(i, "S_YONGHUH");
            //        dr["用户名"] = this.gvYongHuXX.GetRowValues(i, "S_YONGHUM");
            //        dr["用户地址"] = this.gvYongHuXX.GetRowValues(i, "S_DIZHI");
            //        dr["行政区号"] = this.gvYongHuXX.GetRowValues(i, "S_XINGZHENGQBH");
            //        dr["行政区名"] = this.gvYongHuXX.GetRowValues(i, "S_XINGZHENGQM");
            //        dr["业务员"] = this.gvYongHuXX.GetRowValues(i, "S_YEWUY");
            //        dr["部门编号"] = this.gvYongHuXX.GetRowValues(i, "S_BUMENBH");
            //        dr["管理部门"] = this.gvYongHuXX.GetRowValues(i, "S_BUMENMC");
            //        dr["流域"] = this.gvYongHuXX.GetRowValues(i, "S_LIUYUMC");
            //        dr["水资源分区"] = this.gvYongHuXX.GetRowValues(i, "S_SHUIZIYMC");
            //        dr["水利分片"] = this.gvYongHuXX.GetRowValues(i, "S_SHUILIFPMC");
            //        dr["环内环外"] = this.gvYongHuXX.GetRowValues(i, "HNHW");
            //        dr["取水用途"] = this.gvYongHuXX.GetRowValues(i, "S_QUSHUIMC");
            //        dr["行业分类"] = this.gvYongHuXX.GetRowValues(i, "S_FENLEIMC");
            //        dr["水价"] = this.gvYongHuXX.GetRowValues(i, "N_SHUIJIA");
            //        dr["邮政编码"] = this.gvYongHuXX.GetRowValues(i, "S_YOUBIAN");
            //        dr["联系人"] = this.gvYongHuXX.GetRowValues(i, "S_LIANXIR");
            //        dr["联系电话"] = this.gvYongHuXX.GetRowValues(i, "S_DIANHUA");
            //        dr["联系部门"] = this.gvYongHuXX.GetRowValues(i, "S_LIANXIBM");
            //        dr["收费方式"] = this.gvYongHuXX.GetRowValues(i, "SFFS");
            //        dr["开户户名"] = this.gvYongHuXX.GetRowValues(i, "S_KAIHUHM");
            //        dr["银行帐号"] = this.gvYongHuXX.GetRowValues(i, "S_KAIHUH");
            //        dr["开户银行"] = this.gvYongHuXX.GetRowValues(i, "S_KAIHUYH");
            //        dr["井数"] = this.gvYongHuXX.GetRowValues(i, "JS");
            //        dr["表数"] = this.gvYongHuXX.GetRowValues(i, "BS");
            //        dr["开户日期"] = this.gvYongHuXX.GetRowValues(i, "D_TIANJIARQ");
            //        dr["合同号"] = this.gvYongHuXX.GetRowValues(i, "S_HETONGH");
            //        dr["备注"] = this.gvYongHuXX.GetRowValues(i, "S_ZHUSHI");
            //        dt.Rows.Add(dr);
            //    }
            //    PageTools.CreateExcel(dt, sName);

            //}

        }
        
    }
}